package cn.yuemouren.security.core.social.qq.config;

import cn.yuemouren.security.core.properties.SecurityProperties;
import cn.yuemouren.security.core.properties.qq.QQProperties;
import cn.yuemouren.security.core.social.qq.connect.QQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.social.SocialAutoConfigurerAdapter;
import org.springframework.context.annotation.Configuration;
import org.springframework.social.connect.ConnectionFactory;

/**
 * @Author: Timi
 * @Description: QQ自动配置(生成工厂类)
 * @Date: 2020/6/26 15:24
 * @Version: v1.0
 */
@Configuration
@ConditionalOnProperty(prefix = "security.core.social.qq",name = "app-id")
public class QQAutoConfig extends SocialAutoConfigurerAdapter {

    @Autowired
    private SecurityProperties securityProperties;

    @Override
    protected ConnectionFactory<?> createConnectionFactory() {
        QQProperties qq = securityProperties.getSocial().getQq();
        return new QQConnectionFactory(qq.getProviderId(),qq.getAppId(),qq.getAppSecret());
    }
}
